import { Router } from 'express'
import { remove } from '../../db/dao'
import { PROFILE } from '../../db/model'

const router = Router()
router.delete('/delete', function (req, res) {
  const { id } = req.body
  if (!id) {
    return res.status(400).send('missing id!')
  }
  remove(PROFILE, { _id: id }).then(result => {
    res.status(200).json(result)
  }).catch(() => {
    res.status(500).end()
  })
})

export default router
